// src/api/templateDetailApi.js
import axios from 'axios'

const TEMPLATE_URL = '/api/templates/papercut'
const RATING_URL = '/api/ratings/papercut'

/** 1. 获取模板详情 */
export const getTemplateDetails = (id) => {
  return axios.get(`${TEMPLATE_URL}/${id}`)
}

/** 2. 获取平均评分 */
export const getAverageRating = (id) => {
  return axios.get(`${RATING_URL}/${id}/average`)
}

/** 3. 获取评论列表 */
export const getComments = (id) => {
  return axios.get(`${RATING_URL}/${id}`)
}

/** 4. 提交/更新评分和评论 (需要用户ID和模板ID) */
export const submitRatingAndComment = (data) => {
  // data 结构: { user: { id: 1 }, papercut: { id: templateId }, ratingValue: 5, reviewText: '...' }
  return axios.post('/api/ratings', data)
}
